#define _CRT_SECURE_NO_WARNINGS 1


class Solution
{
public:
    int maxSubArray(vector<int>& nums)
    {
        int n = nums.size(), ret = INT_MIN;
        vector<int> dp(n + 1);

        for (int i = 1; i <= n; i++)
        {
            dp[i] = max(nums[i - 1], dp[i - 1] + nums[i - 1]);
            //ret=max(ret,dp[i]);
        }
        for (int i = 1; i <= n; i++)
        {
            ret = max(ret, dp[i]);
        }
        return ret;
    }
};